const { Get, Controller } = require("../decorator/router")
const { HOME_DATA } = require("../dataDB/homeData")
const util = require("../util/util")

@Controller("/home")
class Routes {
    @Get("/swiper")
    async user(ctx, next) {
        let query = ctx.query;
        let data = await HOME_DATA.find(query);
        ctx.body = {
            code: 1,
            result: data[0]
        };
    }
    @Get("/sitenavbd")
    async sitenavbd(ctx, next) {
        let query = ctx.query;
        let findParameter = {};
        let slice = null;
        for (var key in query) {
            findParameter[key] = JSON.parse(query[key]);
        }
        let data = await HOME_DATA.find(findParameter[0], findParameter[1]);
        ctx.body = {
            code: 1,
            result: data
        };
    }
    @Get("/section_box_nav")
    async sectionBoxNav(ctx, next) {
        let query = ctx.query;
        let data = await HOME_DATA.findOne(query);
        ctx.body = {
            code: 1,
            result: data
        };
    }
    @Get("/index_center_wrapper")
    async indexCenterWrapper(ctx, next) {
        let query = ctx.query;
        let data = await HOME_DATA.findOne(query);
        ctx.body = {
            code: 1,
            result: data
        }
    }
    @Get("/section_phone_box")
    async sectionPhoneBox(ctx, next) {
        let query = ctx.query;
        let data = await HOME_DATA.findOne(query);
        ctx.body = {
            code: 1,
            result: data
        }
    }
    @Get("/index_accessory_center")
    async indexAccessoryCenter(ctx, next) {
        let query = ctx.query;
        let dataUrl = await HOME_DATA.findOne(query);
        util.dataErrorReturn({ dataUrl, ctx });
    }
    @Get('/meizu_footer_link')
    async meizuFooterLink(ctx, next) {
        let query = ctx.query
        let dataUrl = await HOME_DATA.findOne(query)
        util.dataErrorReturn({ dataUrl, ctx })
    }
}
